import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DickYang
 * Date: 2023-06-20
 * Time: 12:46
 *
 * 自定义异常
 */
public class Test1 {
    public static void logic() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入用户名: ");
        String name = scanner.nextLine();
        System.out.println("请输入密码: ");
        String password = scanner.nextLine();

        if (!name.equals("admin")) {
            throw new UserNameException("用户名错了");
        }
        if (!password.equals("123456")) {
            throw new UserPassWordException("密码错了");
        }
    }
    public static void main(String[] args) {
        try {
            logic();
        } catch (UserNameException   userNameException) {
            userNameException.printStackTrace();
        } catch (UserPassWordException userPassWordException) {
            userPassWordException.printStackTrace();
        }
    }
}
